#Taken and modified from Daniel Skoog at https://github.com/dskoog/Maple-OEIS/blob/master/src/OEIS.mpl by Austin DeCicco on 3/2/2026 for Dr. Doron Zeilberger's Experimental Mathematics Spring 2026 #Search(1,1,2,3,5,8) = 45, which corresponds to the first result's A-number on OEIS #Revised 9/28/2026: accepted a list as well as a sequence, so Search([1,1,2,3,5,8]) and Search(1,1,2,3,5,8) behave the same; quoted the URL passed to curl, since cmd.exe otherwise treats the & in the query string as a command separator and curl never receives the sequence; replaced type(args,'string') with type([args],[string]), since args splices into the call and made any multi-argument non-integer input fail inside type() itself; reported what was received when the argument check fails; and raised a clear error when curl returns nothing instead of letting the JSON parser fail. URLpath := "https://oeis.org/": Search := proc() option cache; local argsin, i, curl_out, oeis_json, parsed_value, searchstring, cmd; if nargs = 1 and type( args, 'list' ) then return procname( op( args ) ); end if; parsed_value := Array(1..0): if type( [ args ], 'list'('integer') ) = true and nargs < 6 or ( type( [ args ], 'list'('integer') ) = false and not type( [args], [string] ) ) then error "6 or more integers required, given as a sequence or a list; received %1", [args]; elif type( [ args ], 'list'('integer') ) = true then argsin := :-map( :-convert, [ args ], ':-string' ); searchstring := cat( argsin[1], seq( op( [",", argsin[i]] ), i = 2..numelems( argsin ) ) ); elif type( [args], [string] ) then argsin := [args]; searchstring := StringTools:-SubstituteAll(op(argsin), " ", "%20"); else error "6 or more integers required, given as a sequence or a list; received %1", [args]; end if; cmd := cat("curl -s \"", URLpath, "search?fmt=json&q=", searchstring, "\""): curl_out := ssystem(cmd): if curl_out[1] <> 0 or curl_out[2] = "" then error "could not reach oeis.org; check your internet connection and that curl is installed (curl exit code %1)", curl_out[1]; end if: oeis_json := curl_out[2]: parsed_value(1) := eval( JSON:-ParseString( oeis_json ) ); if type(parsed_value[1][1]["number"],integer) then return parsed_value[1][1]["number"]; else return -1; end if; end proc: